<!DOCTYPE html>
<html lang="en">
  <head>
    <title>gir2swift  Reference</title>
    <link rel="stylesheet" type="text/css" href="css/jazzy.css" />
    <link rel="stylesheet" type="text/css" href="css/highlight.css" />
    <meta charset="utf-8">
    <script src="js/jquery.min.js" defer></script>
    <script src="js/jazzy.js" defer></script>
    
    <script src="js/lunr.min.js" defer></script>
    <script src="js/typeahead.jquery.js" defer></script>
    <script src="js/jazzy.search.js" defer></script>
  </head>
  <body>


    <a title="gir2swift  Reference"></a>

    <header class="header">
      <p class="header-col header-col--primary">
        <a class="header-link" href="index.html">
          gir2swift 6.0.0 Docs
        </a>
         (98% documented)
      </p>
    
      <p class="header-col--secondary">
        <form role="search" action="search.json">
          <input type="text" placeholder="Search documentation" data-typeahead>
        </form>
      </p>
    
        <p class="header-col header-col--secondary">
          <a class="header-link" href="https://github.com/rhx/gir2swift">
            <img class="header-icon" src="img/gh.png"/>
            View on GitHub
          </a>
        </p>
    
        <p class="header-col header-col--secondary">
          <a class="header-link" href="dash-feed://http%3A%2F%2Frhx%2Egithub%2Eio%2Fgir2swift%2Fdocsets%2Fgir2swift%2Exml">
            <img class="header-icon" src="img/dash.png"/>
            Install in Dash
          </a>
        </p>
    </header>

    <p class="breadcrumbs">
      <a class="breadcrumb" href="index.html">gir2swift Reference</a>
      <img class="carat" src="img/carat.png" />
      gir2swift  Reference
    </p>

    <div class="content-wrapper">
      <nav class="navigation">
        <ul class="nav-groups">
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="Classes.html">Classes</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/GIR.html">GIR</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/GIR/Thing.html">– Thing</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/GIR/Datatype.html">– Datatype</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/GIR/CType.html">– CType</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/GIR/Alias.html">– Alias</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/GIR/Constant.html">– Constant</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/GIR/Enumeration.html">– Enumeration</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/GIR/Bitfield.html">– Bitfield</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/GIR/Record.html">– Record</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/GIR/Class.html">– Class</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/GIR/Interface.html">– Interface</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/GIR/Method.html">– Method</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/GIR/Function.html">– Function</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/GIR/Callback.html">– Callback</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/GIR/Signal.html">– Signal</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/GIR/Property.html">– Property</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Classes/GIR/Argument.html">– Argument</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="Extensions.html">Extensions</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Extensions/BidirectionalCollection.html">BidirectionalCollection</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Extensions/Collection.html">Collection</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Extensions/Sequence.html">Sequence</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Extensions/String.html">String</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Extensions/String.html">String</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Extensions/String/UTF8View.html">– UTF8View</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Extensions/XMLElement.html">XMLElement</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="Functions.html">Functions</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift1loiySbAA3GIRC5ThingC_AFtF">&lt;(_:_:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift2eeoiySbAA3GIRC5ThingC_AFtF">==(_:_:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift8callCode__3ptrSSAA3GIRC6MethodCcSS_AE6RecordCSgSStF">callCode(_:_:ptr:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift10callSetter__3ptrSSAA3GIRC6MethodCcSS_AE6RecordCSgSStF">callSetter(_:_:ptr:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift7codeFor8argumentSSAA3GIRC8ArgumentC_tF">codeFor(argument:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift7codeFor8argument6prefixSSAA3GIRC8ArgumentC_SStF">codeFor(argument:prefix:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift11commentCode_11indentationSSAA3GIRC5ThingC_SStF">commentCode(_:indentation:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift20computedPropertyCode_6record17publicDesignation3ptrSSAA16GetterSetterPairVcSS_AA3GIRC6RecordCS2StF">computedPropertyCode(_:record:publicDesignation:ptr:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift16constructorParam_6prefixSSAA3GIRC6MethodC_SSSgtF">constructorParam(_:prefix:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift17constructorPrefixySSSgAA3GIRC6MethodCF">constructorPrefix(_:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift26convenienceConstructorCode_11indentation0B017publicDesignation7factory11convertNameSSAA3GIRC6MethodCcAI6RecordCcSS_S3SSbS2SctF">convenienceConstructorCode(_:indentation:convenience:publicDesignation:factory:convertName:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift31convertSetterArgumentToSwiftFor_3ptrSSAA3GIRC0D0CcAE6RecordCSg_SStF">convertSetterArgumentToSwiftFor(_:ptr:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift14deprecatedCode_11indentationSSSgAA3GIRC5ThingC_SStF">deprecatedCode(_:indentation:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift12functionCode_11indentation18initialIndentationSSAA3GIRC8FunctionC_S2StF">functionCode(_:indentation:initialIndentation:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift7get_optySJ_SSSgtSgSSF">get_opt(_:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift17getterSetterPairs3forSayAA06GetterC4PairVGSayAA3GIRC6MethodCG_tF">getterSetterPairs(for:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift15gtkDoc2SwiftDoc_10linePrefixS2S_SStF">gtkDoc2SwiftDoc(_:linePrefix:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift10methodCode_18initialIndentation6record17publicDesignation11convertName3ptrSSAA3GIRC6MethodCcSS_SSSgAI6RecordCSgS3ScSStF">methodCode(_:initialIndentation:record:publicDesignation:convertName:ptr:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift15recordClassCode_6parent11indentation3ptrSSAA3GIRC6RecordC_S3StF">recordClassCode(_:parent:indentation:ptr:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift18recordProtocolCode_6parent11indentation3ptrSSAA3GIRC6RecordC_S3StF">recordProtocolCode(_:parent:indentation:ptr:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift27recordProtocolExtensionCode__11indentation3ptrSSSayAA3GIRC8FunctionCG_AF6RecordCS2StF">recordProtocolExtensionCode(_:_:indentation:ptr:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift16recordStructCode_11indentation3ptrSSAA3GIRC6RecordC_S2StF">recordStructCode(_:indentation:ptr:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift10returnCode__3ptrSSAA3GIRC6MethodCcSS_SS8typeName_AE6RecordC6recordSb13isConstructorSb0K11ConveniencetSgSStF">returnCode(_:_:ptr:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift21returnDeclarationCodeySSAA3GIRC6MethodCcSS8typeName_AD6RecordC6recordSb13isConstructortSgF">returnDeclarationCode(_:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift14returnTypeCodeySSSgAA3GIRC6MethodCcSS8typeName_AE6RecordC6recordSb13isConstructortSgF">returnTypeCode(_:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift14signalNameCode11indentation07convertC0SSAA3GIRC5CTypeCcSS_S2SctF">signalNameCode(indentation:convertName:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift14signalNameCode11indentation8prefixes07convertC0SSAA3GIRC5CTypeCcSS_SS_SStS2SctF">signalNameCode(indentation:prefixes:convertName:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift22swiftCallbackAliasCode8callbackSSAA3GIRC0C0C_tF">swiftCallbackAliasCode(callback:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift9swiftCodeySSAA3GIRC11EnumerationCF">swiftCode(_:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift9swiftCodeySSAA3GIRC6RecordCcSScSayAD8FunctionCGF">swiftCode(_:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift9swiftCodeySSAA3GIRC8FunctionCF">swiftCode(_:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift9swiftCode__11indentationSSAA3GIRC5ThingC_S2StF">swiftCode(_:_:indentation:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift9swiftCode5aliasSSAA3GIRC5AliasC_tF">swiftCode(alias:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift9swiftCode8constantSSAA3GIRC8ConstantC_tF">swiftCode(constant:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift7toSwift_3ptrSSAA3GIRC8ArgumentC_SStF">toSwift(_:ptr:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift9typeAliasySSAA3GIRC11EnumerationCF">typeAlias(_:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift9valueCodeySSAA3GIRC8ConstantCcSSF">valueCode(_:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift9with_mmap_10protection5flags7processySS_s5Int32VAGySRyxGXEtlF">with_mmap(_:protection:flags:process:)</a>
              </li>
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Functions.html#/s:12libgir2swift9with_mmap_10protection5flags7processySS_s5Int32VAGySv_SitXEtF">with_mmap(_:protection:flags:process:)</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a class="nav-group-name-link" href="Structs.html">Structures</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a class="nav-group-task-link" href="Structs.html#/s:12libgir2swift16GetterSetterPairV">GetterSetterPair</a>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
      <article class="main-content">

        <section class="section">
          <div class="section-content">
            
            <h1 id='gir2swift' class='heading'>gir2swift</h1>

<p>A simple GIR parser in Swift for creating Swift types for a .gir file</p>
<h2 id='getting-started' class='heading'>Getting Started</h2>

<p>To start a project that uses Swift wrappers around low-level libraries that utilise gobject-introspection, you need to create some scripts that use <code>gir2swift</code> to convert the information within gobject-introspection XML (<code>.gir</code>) files into Swift.  Here is a brief overview of the basic steps:</p>

<ol>
<li>Install the prerequisites on your system (see <a href="#Prerequisites">Prerequisites</a> below)</li>
<li>Compile <code>gir2swift</code> (see <a href="#Building">Building</a> below)</li>
<li>Create a <a href="https://swift.org/package-manager/">Swift Package Manager</a> module that contains a system target for your underlying low-level library and a library target for the Swift Wrapper library that you want to build</li>
<li>Create the necessary Module files (see <a href="#Module-Files">Module Files</a> below)</li>
<li>Create a script that runs <code>gir2swift</code> (see <a href="#Usage">Usage</a> below) and then builds your project using <code>swift build</code></li>
<li>If the build phase fails (more likely than not), add code that patches the generated Swift source files (e.g. using <code>awk</code> or <code>sed</code>) to correct the errors the compiler complains about</li>
</ol>
<h2 id='usage' class='heading'>Usage</h2>
<h3 id='synopsis' class='heading'>Synopsis</h3>
<pre class="highlight plaintext"><code>gir2swift [-v][-s][-m module_boilerplate.swift]{-p file.gir}[file.gir ...]
</code></pre>
<h3 id='description' class='heading'>Description</h3>

<p><code>gir2swift</code> takes the information from a gobject-introspection XML (<code>file.gir</code>) file and creates corresponding Swift wrappers.  When reading the <code>.gir</code> file, <code>gir2swift</code> also reads a number of <a href="#Module-Files">Module Files</a> that you create with additional information.</p>

<p>The following options are available:</p>

<blockquote>
<p><code>-m Module.swift</code> Add <code>Module.swift</code> as the main (hand-crafted) Swift file for your library target.</p>

<p><code>-o directory</code> Specify the output directory to put the generated files into.</p>

<p><code>-p pre.gir</code> Add <code>pre.gir</code> as a pre-requisite <code>.gir</code> file to ensure the types in <code>file.gir</code> are known</p>

<p><code>-s</code> Create a single <code>.swift</code> file per class</p>

<p><code>-v</code> Produce verbose output.</p>
</blockquote>
<h3 id='examples' class='heading'>Examples</h3>

<p>The following command generates a Swift Wrapper in <code>Sources/GIO</code> from the information in <code>/usr/share/gir-1.0/Gio-2.0.gir</code>, copying the content from <code>Gio-2.0.module</code> and taking into account information in <code>GLib-2.0.gir</code> and <code>GObject-2.0.gir</code>:</p>
<pre class="highlight plaintext"><code>    gir2swift -o Sources/GIO -m Gio-2.0.module -p /usr/share/gir-1.0/GLib-2.0.gir -p /usr/share/gir-1.0/GObject-2.0.gir /usr/share/gir-1.0/Gio-2.0.gir
</code></pre>

<p>The <code>Gio-2.0.module</code> file would need to contain the code that you would want to manually add to your Swift module, for example:</p>
<pre class="highlight plaintext"><code>import CGLib
import GLib
import GLibObject

public struct GDatagramBased {}
public struct GUnixConnectionPrivate {}
public struct GUnixCredentialsMessagePrivate {}
public struct GUnixFDListPrivate {}
public struct GUnixFDMessagePrivate {}
public struct GUnixInputStreamPrivate {}
public struct GUnixOutputStreamPrivate {}
public struct GUnixSocketAddressPrivate {}

func g_io_module_load(_ module: UnsafeMutablePointer&lt;GIOModule&gt;) {
    fatalError("private g_io_module_load called")
}

func g_io_module_unload(_ module: UnsafeMutablePointer&lt;GIOModule&gt;) {
    fatalError("private g_io_module_unload called")
}
</code></pre>

<p>Also you would need a corresponding preamble file <code>Gio-2.0.preamble</code> that imports the necessary low-level libraries, e.g.:</p>
<pre class="highlight plaintext"><code>import CGLib
import GLib
import GLibObject
</code></pre>
<h2 id='module-files' class='heading'>Module Files</h2>

<p>In addition to reading a given <code>Module.gir</code> file, <code>gir2swift</code> also reads a number of module files from the current working directory that contain additional information.  These module files need to have the same name as the <code>.gir</code> file, but have a different file extension:</p>
<h3 id='code-module-preamble-code' class='heading'><code>Module.preamble</code></h3>

<p>This file contains the Swift code that you need to as the preamble for every generated <code>.swift</code> file (e.g. the <code>import</code> statements for all the modules you want to import).</p>
<h3 id='code-module-blacklist-code' class='heading'><code>Module.blacklist</code></h3>

<p>This file contains the symbols (separated by newline) that you want to suppress in your output.  Here you should include all the symbols in the <code>.gir</code> file that the Swift compiler cannot import from the relevant C language headers.</p>
<h3 id='code-module-whitelist-code' class='heading'><code>Module.whitelist</code></h3>

<p>This file contains the symbols (separated by newline) that would otherwise be suppressed (e.g. because <code>gir2swift</code> thinks they are duplicates), but you would like to include in the <code>gir2swift</code> output.</p>
<h3 id='code-module-verbatim-code' class='heading'><code>Module.verbatim</code></h3>

<p>Normally, <code>gir2swift</code> tries to translate constants from C to Swift, as per the definitions in the <code>.gir</code> files.  Names of constants listed (and separated by newline) in this file will not be translated.</p>
<h2 id='prerequisites' class='heading'>Prerequisites</h2>
<h3 id='swift' class='heading'>Swift</h3>

<p>To build, you need at least Swift 4.2 (Swift 5.x should work fine), download from <a href="https://swift.org/download/">https://swift.org/download/</a> &ndash; if you are using macOS, make sure you have the command line tools installed as well).  Test that your compiler works using <code>swift --version</code>, which should give you something like</p>
<pre class="highlight plaintext"><code>$ swift --version
Apple Swift version 5.1 (swiftlang-1100.0.270.13 clang-1100.0.33.7)
Target: x86_64-apple-darwin18.6.0
</code></pre>

<p>on macOS, or on Linux you should get something like:</p>
<pre class="highlight plaintext"><code>$ swift --version
Swift version 5.1 (swift-5.1-RELEASE)
Target: x86_64-unknown-linux-gnu
</code></pre>
<h3 id='libxml-2-9-4-or-higher' class='heading'>LibXML 2.9.4 or higher</h3>

<p>These Swift wrappers have been tested with libxml-2.9.4 and 2.9.9.  They should work with higher versions, but YMMV.  Also make sure you have <code>gobject-introspection</code> and its <code>.gir</code> files installed.</p>
<h4 id='macos' class='heading'>macOS</h4>

<p>On current versions of macOS, you need to install <code>libxml2</code> using HomeBrew (the version that comes with the system does not include the necessary development headers &ndash; for HomeBrew setup instructions, see <a href="http://brew.sh):">http://brew.sh):</a></p>
<pre class="highlight plaintext"><code>brew update
brew install libxml2 gobject-introspection
</code></pre>
<h4 id='linux' class='heading'>Linux</h4>
<h5 id='ubuntu' class='heading'>Ubuntu</h5>

<p>On Ubuntu 16.04 and 18.04, you can use the gtk that comes with the distribution.  Just install with the <code>apt</code> package manager:</p>
<pre class="highlight plaintext"><code>sudo apt update
sudo apt install libxml2-dev gobject-introspection libgirepository1.0-dev
</code></pre>
<h5 id='fedora' class='heading'>Fedora</h5>

<p>On Fedora 29, you can use the gtk that comes with the distribution.  Just install with the <code>dnf</code> package manager:</p>
<pre class="highlight plaintext"><code>sudo dnf install libxml2-devel gobject-introspection-devel
</code></pre>
<h2 id='building' class='heading'>Building</h2>

<p>Normally, you don&rsquo;t build this package directly, but you embed it into your own project (see &lsquo;Embedding&rsquo; below).  However, you can build and test this module separately to ensure that everything works.  Make sure you have all the prerequisites installed (see above).  After that, you can simply clone this repository and build the command line executable (be patient, this will download all the required dependencies and take a while to compile) using</p>
<pre class="highlight plaintext"><code>git clone https://github.com/rhx/gir2swift.git
cd gir2swift
./build.sh
</code></pre>
<h3 id='xcode' class='heading'>Xcode</h3>

<p>On macOS, you can build the project using Xcode instead.  To do this, you need to create an Xcode project first, then open the project in the Xcode IDE:</p>
<pre class="highlight plaintext"><code>./xcodegen.sh
open gir2swift.xcodeproj
</code></pre>

<p>After that, use the (usual) Build and Test buttons to build/test this package.</p>
<h2 id='troubleshooting' class='heading'>Troubleshooting</h2>

<p>Here are some common errors you might encounter and how to fix them.</p>
<h3 id='old-swift-toolchain-or-xcode' class='heading'>Old Swift toolchain or Xcode</h3>

<p>If you get an error such as</p>
<pre class="highlight plaintext"><code>$ ./build.sh 
error: unable to invoke subcommand: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-package (No such file or directory)
</code></pre>

<p>this probably means that your Swift toolchain is too old.  Make sure the latest toolchain is the one that is found when you run the Swift compiler (see above).</p>

<p>If you get an older version, make sure that the right version of the swift compiler is found first in your <code>PATH</code>.  On macOS, use xcode-select to select and install the latest version, e.g.:</p>
<pre class="highlight plaintext"><code>sudo xcode-select -s /Applications/Xcode.app
xcode-select --install
</code></pre>

          </div>
        </section>


      </article>
    </div>
    <section class="footer">
      <p>&copy; 2019 <a class="link" href="https://www.ict.griffith.edu.au/~rhexel/" target="_blank" rel="external">Ren&eacute;&nbsp;Hexel</a>. All rights reserved. (Last updated: 2019-12-12)</p>
      <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.11.2</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
    </section>
  </body>
</div>
</html>
